package jproyinv;

import org.jdesktop.application.SingleFrameApplication;
import org.jdesktop.application.FrameView;
import org.cis.jproyinv.comun.vistas.BuscarDocente;
import org.cis.jproyinv.comun.vistas.BuscarEstudiante;
import org.cis.jproyinv.negocio.UseCaseController;
import org.cis.jproyinv.proyecto.vista.BuscarLineaInvestigacion;
import org.cis.jproyinv.proyecto.vista.BuscarProyectoInvestigacion;
import org.cis.jproyinv.proyecto.vista.ConsultarProyectoInvestigacion;
import org.cis.jproyinv.proyecto.vista.ProyectosCumplidos;
import org.cis.jproyinv.seguridad.dao.HistorialDao;
import org.cis.jproyinv.seguridad.vista.BuscarUsuario;

public class JproyinvView extends FrameView {

    public JproyinvView(SingleFrameApplication app) {
        super(app);
        initComponents();
        HistorialDao hi = new HistorialDao();
        if (hi.buscarUsuario().getRol().equals("Administrador de Proyectos")) {
            jitAdminU.setVisible(false);
            jitRespaldar.setVisible(false);
        } else if (hi.buscarUsuario().getRol().equals("Usuario")) {
            jitAdminD.setVisible(false);
            jitAdminE.setVisible(false);
            jitAdminL.setVisible(false);
            jitAdminP.setVisible(false);
            jitAdminU.setVisible(false);
            jitRespaldar.setVisible(false);
        }
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        mainPanel = new javax.swing.JPanel();
        panelImage1 = new org.edisoncor.gui.panel.PanelImage();
        panelCurves1 = new org.edisoncor.gui.panel.PanelCurves();
        clockFace1 = new org.edisoncor.gui.varios.ClockFace();
        menuBar = new javax.swing.JMenuBar();
        javax.swing.JMenu fileMenu = new javax.swing.JMenu();
        javax.swing.JMenuItem exitMenuItem = new javax.swing.JMenuItem();
        jMenu2 = new javax.swing.JMenu();
        jitAdminD = new javax.swing.JMenuItem();
        jitAdminE = new javax.swing.JMenuItem();
        jitAdminL = new javax.swing.JMenuItem();
        jitAdminP = new javax.swing.JMenuItem();
        jitAdminU = new javax.swing.JMenuItem();
        jMenu1 = new javax.swing.JMenu();
        jitConsul = new javax.swing.JMenuItem();
        jMenuItem2 = new javax.swing.JMenuItem();
        javax.swing.JMenu helpMenu = new javax.swing.JMenu();
        javax.swing.JMenuItem jitAyuda = new javax.swing.JMenuItem();
        jitRespaldar = new javax.swing.JMenuItem();
        statusPanel = new javax.swing.JPanel();
        javax.swing.JSeparator statusPanelSeparator = new javax.swing.JSeparator();
        statusMessageLabel = new javax.swing.JLabel();
        statusAnimationLabel = new javax.swing.JLabel();
        progressBar = new javax.swing.JProgressBar();

        mainPanel.setName("mainPanel"); // NOI18N

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(jproyinv.JproyinvApp.class).getContext().getResourceMap(JproyinvView.class);
        panelImage1.setIcon(resourceMap.getIcon("panelImage1.icon")); // NOI18N
        panelImage1.setName("panelImage1"); // NOI18N

        panelCurves1.setName("panelCurves1"); // NOI18N

        clockFace1.setName("clockFace1"); // NOI18N

        javax.swing.GroupLayout clockFace1Layout = new javax.swing.GroupLayout(clockFace1);
        clockFace1.setLayout(clockFace1Layout);
        clockFace1Layout.setHorizontalGroup(
            clockFace1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 86, Short.MAX_VALUE)
        );
        clockFace1Layout.setVerticalGroup(
            clockFace1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 84, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout panelCurves1Layout = new javax.swing.GroupLayout(panelCurves1);
        panelCurves1.setLayout(panelCurves1Layout);
        panelCurves1Layout.setHorizontalGroup(
            panelCurves1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelCurves1Layout.createSequentialGroup()
                .addGap(21, 21, 21)
                .addComponent(clockFace1, javax.swing.GroupLayout.PREFERRED_SIZE, 86, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(599, Short.MAX_VALUE))
        );
        panelCurves1Layout.setVerticalGroup(
            panelCurves1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelCurves1Layout.createSequentialGroup()
                .addContainerGap(311, Short.MAX_VALUE)
                .addComponent(clockFace1, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(78, 78, 78))
        );

        javax.swing.GroupLayout panelImage1Layout = new javax.swing.GroupLayout(panelImage1);
        panelImage1.setLayout(panelImage1Layout);
        panelImage1Layout.setHorizontalGroup(
            panelImage1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(panelCurves1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        panelImage1Layout.setVerticalGroup(
            panelImage1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(panelCurves1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout mainPanelLayout = new javax.swing.GroupLayout(mainPanel);
        mainPanel.setLayout(mainPanelLayout);
        mainPanelLayout.setHorizontalGroup(
            mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(panelImage1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        mainPanelLayout.setVerticalGroup(
            mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(panelImage1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        menuBar.setName("menuBar"); // NOI18N

        fileMenu.setBackground(resourceMap.getColor("fileMenu.background")); // NOI18N
        fileMenu.setForeground(resourceMap.getColor("fileMenu.foreground")); // NOI18N
        fileMenu.setText(resourceMap.getString("fileMenu.text")); // NOI18N
        fileMenu.setName("fileMenu"); // NOI18N

        javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance(jproyinv.JproyinvApp.class).getContext().getActionMap(JproyinvView.class, this);
        exitMenuItem.setAction(actionMap.get("quit")); // NOI18N
        exitMenuItem.setName("exitMenuItem"); // NOI18N
        fileMenu.add(exitMenuItem);

        menuBar.add(fileMenu);

        jMenu2.setForeground(resourceMap.getColor("jMenu2.foreground")); // NOI18N
        jMenu2.setText(resourceMap.getString("jMenu2.text")); // NOI18N
        jMenu2.setName("jMenu2"); // NOI18N

        jitAdminD.setText(resourceMap.getString("jitAdminD.text")); // NOI18N
        jitAdminD.setName("jitAdminD"); // NOI18N
        jitAdminD.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jitAdminDActionPerformed(evt);
            }
        });
        jMenu2.add(jitAdminD);

        jitAdminE.setText(resourceMap.getString("jitAdminE.text")); // NOI18N
        jitAdminE.setName("jitAdminE"); // NOI18N
        jitAdminE.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jitAdminEActionPerformed(evt);
            }
        });
        jMenu2.add(jitAdminE);

        jitAdminL.setText(resourceMap.getString("jitAdminL.text")); // NOI18N
        jitAdminL.setName("jitAdminL"); // NOI18N
        jitAdminL.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jitAdminLActionPerformed(evt);
            }
        });
        jMenu2.add(jitAdminL);

        jitAdminP.setText(resourceMap.getString("jitAdminP.text")); // NOI18N
        jitAdminP.setName("jitAdminP"); // NOI18N
        jitAdminP.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jitAdminPActionPerformed(evt);
            }
        });
        jMenu2.add(jitAdminP);

        jitAdminU.setText(resourceMap.getString("jitAdminU.text")); // NOI18N
        jitAdminU.setName("jitAdminU"); // NOI18N
        jitAdminU.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jitAdminUActionPerformed(evt);
            }
        });
        jMenu2.add(jitAdminU);

        menuBar.add(jMenu2);

        jMenu1.setForeground(resourceMap.getColor("jMenu1.foreground")); // NOI18N
        jMenu1.setText(resourceMap.getString("jMenu1.text")); // NOI18N
        jMenu1.setName("jMenu1"); // NOI18N

        jitConsul.setText(resourceMap.getString("jitConsultas.text")); // NOI18N
        jitConsul.setName("jitConsultas"); // NOI18N
        jitConsul.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jitConsulActionPerformed(evt);
            }
        });
        jMenu1.add(jitConsul);

        jMenuItem2.setText(resourceMap.getString("jMenuItem2.text")); // NOI18N
        jMenuItem2.setName("jMenuItem2"); // NOI18N
        jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem2ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem2);

        menuBar.add(jMenu1);

        helpMenu.setForeground(resourceMap.getColor("helpMenu.foreground")); // NOI18N
        helpMenu.setText(resourceMap.getString("helpMenu.text")); // NOI18N
        helpMenu.setName("helpMenu"); // NOI18N
        helpMenu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                helpMenuActionPerformed(evt);
            }
        });

        jitAyuda.setAction(actionMap.get("showAboutBox")); // NOI18N
        jitAyuda.setText(resourceMap.getString("jitAyuda.text")); // NOI18N
        jitAyuda.setName("jitAyuda"); // NOI18N
        jitAyuda.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jitAyudaActionPerformed(evt);
            }
        });
        helpMenu.add(jitAyuda);

        jitRespaldar.setText(resourceMap.getString("jitRespaldar.text")); // NOI18N
        jitRespaldar.setName("jitRespaldar"); // NOI18N
        jitRespaldar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jitRespaldarActionPerformed(evt);
            }
        });
        helpMenu.add(jitRespaldar);

        menuBar.add(helpMenu);

        statusPanel.setName("statusPanel"); // NOI18N

        statusPanelSeparator.setName("statusPanelSeparator"); // NOI18N

        statusMessageLabel.setName("statusMessageLabel"); // NOI18N

        statusAnimationLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        statusAnimationLabel.setName("statusAnimationLabel"); // NOI18N

        progressBar.setName("progressBar"); // NOI18N

        javax.swing.GroupLayout statusPanelLayout = new javax.swing.GroupLayout(statusPanel);
        statusPanel.setLayout(statusPanelLayout);
        statusPanelLayout.setHorizontalGroup(
            statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(statusPanelSeparator, javax.swing.GroupLayout.DEFAULT_SIZE, 706, Short.MAX_VALUE)
            .addGroup(statusPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(statusMessageLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 686, Short.MAX_VALUE)
                .addComponent(statusAnimationLabel)
                .addContainerGap())
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, statusPanelLayout.createSequentialGroup()
                .addContainerGap(536, Short.MAX_VALUE)
                .addComponent(progressBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(24, 24, 24))
        );
        statusPanelLayout.setVerticalGroup(
            statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(statusPanelLayout.createSequentialGroup()
                .addComponent(statusPanelSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 2, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(statusMessageLabel)
                    .addComponent(statusAnimationLabel)
                    .addComponent(progressBar, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(3, 3, 3))
        );

        setComponent(mainPanel);
        setMenuBar(menuBar);
        setStatusBar(statusPanel);
    }// </editor-fold>//GEN-END:initComponents

private void jitAdminDActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jitAdminDActionPerformed
    BuscarDocente buscar = new BuscarDocente(false);
    buscar.setVisible(true);
}//GEN-LAST:event_jitAdminDActionPerformed

private void jitAdminEActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jitAdminEActionPerformed
    BuscarEstudiante buscar = new BuscarEstudiante(false);
    buscar.setVisible(true);
}//GEN-LAST:event_jitAdminEActionPerformed

private void jitAdminLActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jitAdminLActionPerformed
    BuscarLineaInvestigacion buscar = new BuscarLineaInvestigacion();
    buscar.setVisible(true);
}//GEN-LAST:event_jitAdminLActionPerformed

private void jitAdminPActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jitAdminPActionPerformed
    BuscarProyectoInvestigacion buscar = new BuscarProyectoInvestigacion();
    buscar.setVisible(true);
}//GEN-LAST:event_jitAdminPActionPerformed

private void jitAdminUActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jitAdminUActionPerformed
    BuscarUsuario buscar = new BuscarUsuario();
    buscar.setVisible(true);
}//GEN-LAST:event_jitAdminUActionPerformed

private void helpMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_helpMenuActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_helpMenuActionPerformed

private void jitAyudaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jitAyudaActionPerformed
    JproyinvViewAyuda ayuda = new JproyinvViewAyuda();
    ayuda.setVisible(true);
}//GEN-LAST:event_jitAyudaActionPerformed

private void jitConsulActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jitConsulActionPerformed
    ConsultarProyectoInvestigacion buscar = new ConsultarProyectoInvestigacion();
    buscar.setVisible(true);
}//GEN-LAST:event_jitConsulActionPerformed

private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed
    ProyectosCumplidos cumplidos = new ProyectosCumplidos();
    cumplidos.setVisible(true);
}//GEN-LAST:event_jMenuItem2ActionPerformed

private void jitRespaldarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jitRespaldarActionPerformed
    new UseCaseController().respaldarBaseDeDatos();
}//GEN-LAST:event_jitRespaldarActionPerformed
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private org.edisoncor.gui.varios.ClockFace clockFace1;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenuItem jMenuItem2;
    private javax.swing.JMenuItem jitAdminD;
    private javax.swing.JMenuItem jitAdminE;
    private javax.swing.JMenuItem jitAdminL;
    private javax.swing.JMenuItem jitAdminP;
    private javax.swing.JMenuItem jitAdminU;
    private javax.swing.JMenuItem jitConsul;
    private javax.swing.JMenuItem jitRespaldar;
    private javax.swing.JPanel mainPanel;
    private javax.swing.JMenuBar menuBar;
    private org.edisoncor.gui.panel.PanelCurves panelCurves1;
    private org.edisoncor.gui.panel.PanelImage panelImage1;
    private javax.swing.JProgressBar progressBar;
    private javax.swing.JLabel statusAnimationLabel;
    private javax.swing.JLabel statusMessageLabel;
    private javax.swing.JPanel statusPanel;
    // End of variables declaration//GEN-END:variables
}
